/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

package org.opu.vcforms.template;

import org.opu.vcforms.template.bean.Var;

/**
 *
 * @author yura
 */
public class VarDelegator implements Delegator{
    public static final String FORMAT = "format";
    public static final String VARTYPE = "var-type";

    private Var var = new Var();

    @Override
    public void setProperty(String key, String value){
        if (FORMAT.equals(key)){
            var.setFormat(value);
        } else if (VARTYPE.equals(key)){
            Validator.assertIsOneOf("Can't init var data", value, Var.TYPE_CALC,
                    Var.TYPE_SETTINGS, Var.TYPE_CONTENT, Var.TYPE_TEXT);
            var.setType(value);
        } else {
            var.setProperty(key, value);
        }
    }

    public Var getVar() {
        return var;
    }

    public void setVar(Var var) {
        this.var = var;
    }

    @Override
    public void setText(String text) {
        var.setText(text);
    }
}
